﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Documents;
using Caliburn.Core.InversionOfControl;
using Caliburn.PresentationFramework;
using Caliburn.PresentationFramework.Screens;
using MTGenome.MTG;

namespace MTGenome.ViewModels
{
    [Singleton(typeof(AboutViewModel)), PartCreationPolicy(CreationPolicy.Shared)]
    public sealed class AboutViewModel : Screen
    {
        private readonly FlowDocument _text = null;

        public AboutViewModel(IGathererServer gatherer)
        {
            using (FileStream stream = File.OpenRead(gatherer.DataDirectory + "\\Docs\\License.rtf"))
            {
                FlowDocument doc = new FlowDocument();
                TextRange textRange = new TextRange(doc.ContentStart, doc.ContentEnd);
                textRange.Load(stream, DataFormats.Rtf);
                _text = doc;
            }
        }

        public FlowDocument Text
        {
            get { return _text; }
        }
    }
}
